package main

import (
	"encoding/hex"
	"fmt"
)

var VERSION string = "CHUNSOURCE_FORWARD_1.0"             //传输协议标志
var ERRORSTREAM string = "CHUNSOURCE_FORWARD_ERRORSTREAM" //错误流标志

var NEWPORT string = "NEWPORT"       //NEWPORT 开放端口
var CLOSEPORT string = "CLOSEPORT"   //CLOSEPORT 关闭端口
var CHECKEXIST string = "CHECKEXIST" //CHECKEXIST 校验当前端口
var ISOCCUPY string = "ISOCCUPY"     //端口被占用
var ERRORDATA string = "ERRORDATA"   //数据不正确
var PORTOPEN string = "PORTOPEN"     //端口已开启
var ADDSERVICE string = "ADDSERVICE" //增加服务的反向连接的数量

type ForwardInfo struct {
	appPort        int32
	forwardPort    int32
	forwardTimeout int32
	appTimeout     int32
	appHost        [128]byte
	forwardHost    [128]byte
}

const (
	DONE    = 0
	SUCCESS = 1
	FAILED  = 2
	WAIT    = 3
)

//字符惨转成16进制字符窜
func StringToHexstring(str string) string {
	hexString := hex.EncodeToString([]byte(str))
	return hexString
}

//16进制字符串还原
func HexstringToByte(hexstring string) []byte {
	sByte, error := hex.DecodeString(hexstring)
	if error == nil {
		fmt.Println("hex string 还原失败")
	}
	return (sByte)
}
